#include <bits/stdc++.h>
using namespace std;
int n,r[1000010],ans;
int minn=100010,cnt;
int vis[1000010];
bool cmp(int x222,int y222){
    return x222>y222;
}
void dfs(int now,int xu){
    if(now>n){
        for(int i = 1;i<=n;i++){
            if(vis[i]==1) cnt++;
        }
        minn=min(minn,cnt);
    }else{
        vis[now]=1;
        if(r[now]>r[xu]) vis[xu]=2;
        for(int i = 1;i<=n;i++){
            if(now+1!=i&&vis[now+1]!=2&&vis[i]!=2) dfs(now+1,i);
        }
    }
}
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    scanf("%d",&n);
    int ans1=0,ans2=0;
    for(int i = 1;i<=n;i++){
        scanf("%d",&r[i]);
        if(r[i]==1) ans1++;
        else if(r[i]==2) ans2++;
    }
    sort(r+1,r+n+1,cmp);
    if(ans1+ans2==n){
        minn=min(ans1,ans2);
        ans=n-minn;
        cout << ans;
    }else{
        for(int i = 2;i<=n;i++){
            for(int j = 1;j<=n;j++) vis[j]=0;
            dfs(1,i);
        }
        cout << minn;
    }
    return 0;
}
